import de.d3fact.common.events.Event;
import de.d3fact.common.events.IListener;
import de.d3fact.mfslib.buffer.elective.AndElectiveBuffer;
import de.d3fact.modelapi.dataport.IDataport;
import de.d3fact.modelapi.dataport.pull.IntPullOutputport;

/*
 * Zeichnet den Bufferlevel auf und gibt diese mit toString() zurueck
 */
class BufferLevelListener implements IListener{
	private String level;
	private int totalcap;
	private AndElectiveBuffer buffer;
	public BufferLevelListener(int totalcap, AndElectiveBuffer buffer) {
		super();
		level=new String();
		level="";
		this.totalcap=totalcap;
		this.buffer=buffer;
	}
	public void handleEvent(Event e) {
		level=level+Integer.toString(totalcap-buffer.<IntPullOutputport> getPort(AndElectiveBuffer.DATAPORT_FREE_CAPACITY, IDataport.DIRECTION_OUTPUT).value())+", ";
	}
	public String toString(){
		
		return level;
	}
}
